'use strict';
const {
	bodyAnalysis,
	imageProcess
} = require('baidu')
exports.main = async (event, context) => {
	return new Promise(function(resolve, reject) {

		if (event.type == '1') {
			bodyAnalysis.bodySegV1(event.content).then(function(result) {
				resolve(result)
			}).catch(function(err) {
				// 如果发生网络错误
				console.log(err);
				reject(err)
				return "error"
			});

		} else if (event.type == '2') {
			imageProcess.selfieAnime(event.content, {
				type: 'anime'
			}).then(function(result) {
				resolve(result)
			}).catch(function(err) {
				// 如果发生网络错误
				console.log(err);
				reject(err)
				return "error"
			});
		}

	})
};